/**
 * 订单相关接口 
 */
var request = require('./request.js');
module.exports = {
  /**
   * 根据状态分页查询订单
   * @param page 当前页码，起始于1
   * @param pageSize 每页记录数，必须大于等于0且小于等于100，等于0时表示不分页查询全部数据， 大于0时表示分页查询
   * @param memberId 会员标识
   * @param business 业态 RETAIL 零售,CATERING 餐饮,RETAIL_CATERING 零售和餐饮,不填代表查询所有订单 
   * Available values : RETAIL, CATERING, DISTRIBUTION, RETAIL_CATERING, ADVANCE_SELL, SCORE
   */
  query: function (page, pageSize, memberId, business) {
    var params = {
      page: page,
      pageSize: pageSize,
      memberIdEquals: memberId,
      businessEquals: business,
      searchCount: true
    }
    return request.get('/mall/order/query', params)
  },
  /**
   * 查询订单详情
   * 根据订单标识查询具体订单详情
   *  @param orderId 订单Id
   */
  getDetailsById: function (orderId) {
    var params = {
      orderId: orderId
    }
    return request.get('/mall/order/getDetailsById', params)
  },
  /**
   * 取消订单
   */
  cancel: function (orderId) {
    return request.put('/mall/order/cancel?orderId=' + orderId)
  },
  /**
   * 确认订单
   */
  confirm: function (orderId) {
    return request.put('/mall/order/confirm?orderId=' + orderId)
  },

  /**
   * 创建积分商城订单
   */
  createScoreOrder: function (postData) {
    return request.post('/mall/order/createScoreOrder', postData);
  }
}